import request from "@/utils/request";
// 用户相关API
const API = {
  LOGIN_URL: '/login', // 用户登录
  REG_URL: '/register', // 用户注册
  CODE_URL: '/generateCaptcha', // 获取验证码接口
  GET_USER_INFO: '/home/getInfo', // 获取用户信息接口
  GET_USER_LIST: '/home/getUserList', // 获取用户列表接口
  FOLLOW: '/user/giveFollow', // 关注接口
  ISFOLLOW: '/article/isFollowed', //判断是否关注
  UPDATE_USER_INFO: '/user/updateUserInfo', // 更新用户信息接口
  GET_FOLLOW_LIST: '/user/getFollowList', // 获取关注列表接口
  GET_FOLLOWER_LIST: '/user/getFansList', // 获取粉丝列表接口
  MODIFY_PSWD: '/user/modifyPassword', // 修改密码接口
  DELETE_USER: '/user/deleteUser', // 删除用户接口
}

// 用户登录接口
export const reqUserLog = (data) => request.post(API.LOGIN_URL, data)

// 用户注册接口
export const reqUserReg = (data) => request.post(API.REG_URL, data)

// 获取验证码接口
export const reqGetCode = () => request.get(API.CODE_URL)

// 获取用户信息接口
export const reqGetUserInfo = (params) => request.get(API.GET_USER_INFO + `?userId=${params}`)

// 获取用户列表接口
export const reqGetUserList = (params) => request.get(API.GET_USER_LIST + `?id=${params.userId}&num=${params.num}`)

// 关注接口
export const reqFollow = (params) => request.get(API.FOLLOW + `?followerId=${params.followerId}&followeeId=${params.followeeId}`)

// 判断是否关注
export const reqIsFollow = (params) => request.get(API.ISFOLLOW + `?followerId=${params.followerId}&followeeId=${params.followeeId}`)

// 更新用户信息接口
export const reqUpdateUserInfo = (form) => request.post(API.UPDATE_USER_INFO, form)

// 获取关注列表接口
export const reqGetFollowList = (userId) => request.get(API.GET_FOLLOW_LIST + `?userId=${userId}`)

// 获取粉丝列表接口
export const reqGetFollowerList = (userId) => request.get(API.GET_FOLLOWER_LIST + `?userId=${userId}`)

// 修改密码接口 userId, oldPassword, newPassword
export const reqModifyPswd = (data) => request.post(API.MODIFY_PSWD, data)

// 删除用户接口
export const reqDeleteUser = (userId) => request.delete(API.DELETE_USER + `?id=${userId}`)